// import { request } from "./request";
const code = (module.exports = {
  getCode(accessToken,data) {
    return new Promise((resolve, reject) => {
      uni.request({
        url: "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken,
        data,
        method: "POST",
        header: {
          "Content-type": "application/json",
        },
        success: (resp) => {
          resolve(resp);
        },
        fail: (error) => {
          reject(error);
        },
      });
    });
  },
  getAccessToken() {
    return new Promise((resolve, reject) => {
      uni.request({
        url: "https://api.weixin.qq.com/cgi-bin/token",
        data: {
          grant_type: "client_credential",
          appid: "wxecfa6aa57de0d8f6",
          secret: "18be02d442ea43cdbd8f6f5057523ff8",
        },
        method: "GET",
        header: {
          "Content-type": "application/x-www-form-urlencoded",
        },
        success: (resp) => {
          resolve(resp.data);
        },
        fail: (error) => {
          reject(error);
        },
      });
    });
  },
});
